package test.com.sky.designPattern.statePattern;

import com.sky.JULLog.MyLogger;

import java.util.logging.Logger;

/**
 * 运行状态
 * */
public class RunningState extends LiftState {
    private Logger log = MyLogger.getLogger(RunningState.class) ;

    RunningState(Lift lift) {
        super(lift);
    }


    @Override
    public void open() {
        //  throw  exception
        log.severe("运行状态，不能执行开门动作");
    }

    @Override
    public void close() {

        //  throw  exception
        log.severe("运行状态，不能执行关门动作");
    }

    @Override
    public void run() {
        // 运行动作
       log.info("电梯上下运行中...");
    }

    @Override
    public void stop() {
        // 停止动作
        // 1、转化为停止状态
        this.lift.setState(lift.getStoppingState());
        // 2、停止动作
        this.lift.stop();
    }

}

